using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Web.Mail;
/// <summary>
/// Summary description for MailClass
/// </summary>
public class MailClass
{
	public MailClass()
	{
		//
		// TODO: Add constructor logic here
		//
    }
    private string errorMessage = "";
    public string ErrorMessage
    {
        set { errorMessage = value; }
        get { return errorMessage; }
    }
	public bool SendMail(string emailTo, string subject, string body)
	{
	    bool send=true;
	    try
	    {
	        MailMessage mailMessage = new MailMessage();
	        mailMessage.To= emailTo;
	        mailMessage.Subject= subject;
	        mailMessage.Body= body;
	        mailMessage.BodyFormat= MailFormat.Html;
	        mailMessage.Priority = MailPriority.High;
	        SmtpMail.SmtpServer = "mai@recruitvietnam.com";
	        SmtpMail.Send(mailMessage);
	    }
	    catch(Exception ex)
	    {
            send=false;
	        errorMessage=ex.Message;
	        
	    }
        return send;
	}
    public bool SendMail(string emailTo, string emailCC, string emailBCC, string subject, string body)
    {
        bool send = true;
        try
        {
            MailMessage mailMessage = new MailMessage();
            mailMessage.To = emailTo;
            mailMessage.Subject = subject;
            if(emailCC != "")
                mailMessage.Cc = emailCC;
            if (emailBCC != "")
                mailMessage.Bcc = emailBCC;
            mailMessage.Body = body;
            mailMessage.BodyFormat = MailFormat.Html;
            mailMessage.Priority = MailPriority.High;
            SmtpMail.SmtpServer = "mai@recruitvietnam.com";
            SmtpMail.Send(mailMessage);
        }
        catch (Exception ex)
        {
            send = false;
            errorMessage = ex.Message;

        }
        return send;
    }
    public bool SendMail(string emailTo, string emailCC, string emailBCC, string subject, string body, string  attachFileName)
    {
        bool send = true;
        try
        {
            MailMessage mailMessage = new MailMessage();
            mailMessage.To = emailTo;
            mailMessage.Subject = subject;
            if (emailCC != "")
                mailMessage.Cc = emailCC;
            if (emailBCC != "")
                mailMessage.Bcc = emailBCC;
            mailMessage.Body = body;
            if(attachFileName != "")
                {
                    MailAttachment mailAttachment = new MailAttachment(attachFileName);
                    mailMessage.Attachments.Add(mailAttachment);
                }
            mailMessage.BodyFormat = MailFormat.Html;
            mailMessage.Priority = MailPriority.High;
            SmtpMail.SmtpServer = "mai@recruitvietnam.com";
            SmtpMail.Send(mailMessage);
        }
        catch (Exception ex)
        {
            send = false;
            errorMessage = ex.Message;

        }
        return send;
    }
}
